package com.longcai.piaojia.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/7.
 */
@HttpInlet(Conn.COMMENT_VIEW)
public class EvaluateDetailGet extends BaseAsyGet<EvaluateDetailGet.EvaluateDetailEntity> {

    public String user_id, show_id, member_id, posttime;

    public EvaluateDetailGet(AsyCallBack<EvaluateDetailEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected EvaluateDetailEntity parser(JSONObject object) throws Exception {

        if(object.optInt("code")==200){

            EvaluateDetailEntity evaluateDetailEntity = new EvaluateDetailEntity();

            JSONObject jsonObject = object.optJSONObject("info");

            evaluateDetailEntity.user_id = jsonObject.optString("user_id");
            evaluateDetailEntity.star = jsonObject.optString("star");
            evaluateDetailEntity.content = jsonObject.optString("content");
            evaluateDetailEntity.zambia = jsonObject.optString("zambia");
            evaluateDetailEntity.datetime = jsonObject.optString("datetime");
            evaluateDetailEntity.nickname = jsonObject.optString("nickname");
            evaluateDetailEntity.avatar = Conn.BASE_URL + jsonObject.optString("avatar");
            evaluateDetailEntity.zambia_state = jsonObject.optString("zambia_state");
            evaluateDetailEntity.posttime = jsonObject.optString("posttime");

//            JSONArray jsonArray = jsonObject.optJSONArray("img");
//            for(int i=0;i<jsonArray.length();i++){
//
//                JSONObject jsonObject_Img = jsonArray.optJSONObject(i);
//
//                EvaluateDetailImgEntity evaluateDetailImgEntity = new EvaluateDetailImgEntity();
//                evaluateDetailImgEntity.pic = jsonObject_Img.optString("pic");
//
//                evaluateDetailEntity.img.add(evaluateDetailImgEntity);
//
//            }

            return evaluateDetailEntity;

        }

        TOAST = object.optString("message");

        return null;
    }

    public static class EvaluateDetailEntity{

        public String user_id, star, content, zambia, datetime, nickname, avatar, zambia_state, posttime, picarr;

        public List<EvaluateDetailImgEntity> img = new ArrayList<>();

    }

    public static class EvaluateDetailImgEntity{

        public String pic;

    }

}
